/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package creature;

import java.awt.Color;
import world.World;

/**
 *
 * @author leadiv
 *  By Default a creature is a small green 1 pixel dot that runs east to west.
 */
public class Spore1 extends Creature {

    public Spore1(int x, int y, int id) {
        super(x,y,id);
        this.setSkinColor(new Color(128, 172, 255));
    }
    
    @Override
    public void move(World w) 
    {
        Color spore2 = new Color(64, 128, 255);
        Color spore1 = this.getSkinColor();
        
        if (w.getpix(this.getX() - 1, this.getY() + 1).equals(Color.BLACK) && w.getpix(this.getX() + 1, this.getY() + 1).equals(Color.BLACK) && w.getpix(this.getX(), this.getY() + 1).equals(Color.BLACK)) w.place(this.getX(), this.getY() + 1, this.getId());
        else if (w.getpix(this.getX() - 1, this.getY()).equals(spore2) && w.getpix(this.getX() - 1, this.getY() - 1).equals(Color.BLACK)) w.place(this.getX(), this.getY() - 1, this.getId());
        else if (w.getpix(this.getX() - 1, this.getY()).equals(spore2) && w.getpix(this.getX() - 1, this.getY() - 1).equals(Color.BLACK)) w.place(this.getX() - 1, this.getY() - 1, this.getId());
        else if (w.getpix(this.getX() + 1, this.getY()).equals(spore1) && !w.getpix(this.getX() + 1, this.getY() - 1).equals(Color.BLACK)) w.place(this.getX(), this.getY() - 1, this.getId());
        else if (w.getpix(this.getX() + 1, this.getY()).equals(spore1) && w.getpix(this.getX() + 1, this.getY() - 1).equals(Color.BLACK)) w.place(this.getX() + 1, this.getY() - 1, this.getId());
        else w.place(this.getX() + (int)(Math.random() * 3) - 1, this.getY(), this.getId());
    }
}
